const { Tray } = require('electron');
const path = require('path');

function createTray(app,win) {
    const tray = new Tray(path.resolve(__dirname,'./imgs/icon.png'))
    tray.setToolTip('我的vue3应用')
    tray.on('click', (e) => {
        // 如果按住shift+单击鼠标
        if (e.shiftKey) {
            // 关闭应用
            app.quit()
        } else {
            // isVisible 判断当前窗口是否显示
            win.isVisible() ? win.hide() : win.show();
        }
    })


    return tray;
};

module.exports = createTray